$(function () {
	yanzheng($("#email"),$("#code"));
});

//验证手机格式


//验证发送时间
var nums = 60;
function yanzheng(pNumber,code){ //验证码验证
	var conOff = false;
	var clock = '';
	pNumber.bind('input propertychange',function(){
		if( $(this).val().length > 0 ){
			if (isEmail($(this).val())) {
				if(nums ==60 || nums ==0){
					code.css({
						background:"#0DB664",
						color:"#fff"
					});
					conOff = true;
				}
			}else{
				easyAlert("请输入有效的邮箱号.");
				code.css({
					background:"#fff",
					color:"#eaeaea"
				});
				conOff = false;
			}
		}
	})
	code.one("click",function(){
		if( conOff == true){
			checkPhoneIsExist(code);
		}
	});
//	code.bind('click',function(){
//		if( conOff == true){
//			checkPhoneIsExist(code);
//
//		}
//	});
	function checkPhoneIsExist() {
		$.ajax({
			type : "post",
			url : server_url
					+ 'rest/tea/info/updateWeixinForuser.do?ran=' + Math.random(),
			dataType : 'json',
			async : true,
			data : {
				usersid:localStorage.getItem('userid'),
				email:$("#email").val()
			},
			success : function(result) {
				//console.log(result);
				easyAlert("验证码已发送至邮箱,请查收!");
			}
		});
	}
}


function isEmail(userNumb){//验证手机号码
	var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/;
	return reg.test(userNumb);
};